package com.struts.web.corpor.manage.infomanage;

import java.io.PrintWriter;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ibatis.po.user.TSubStation;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.lg.system.CLGAction;
import com.lg.system.CSqlMap;
public class AddPoAjaxAction extends CLGAction {
    
	public ActionForward execute(ActionMapping actionMapping,
            ActionForm actionForm,
            HttpServletRequest request,
            HttpServletResponse response) throws Exception {
		response.setContentType("text/xml");
		response.setCharacterEncoding("UTF-8");
		String sortId = request.getParameter("selected");
		PrintWriter out = response.getWriter();
		SqlMapClient sqlmap = CSqlMap.getSqlMapConfig();
		List subStationList = null;
		TSubStation subStationPo = new TSubStation();
		try{
		//生成岗位列表
			subStationList = sqlmap.queryForList("T_SUB_STATION.selectBySortId",sortId);
		out.println("<response>");
		for(int i=0;i<subStationList.size();i++){
			subStationPo = (TSubStation)subStationList.get(i);
			out.println("<substation>");
			out.println("<stationname>"+subStationPo.getPostName()+"</stationname>");
			out.println("<stationvalue>"+subStationPo.getId()+"</stationvalue>");
			out.println("</substation>");
		}
		out.println("</response>");
		out.flush();
		out.close();
		}catch(Exception e){
			e.printStackTrace();
		}
		return null;	
	 }
	
}
